package com.ks.member.controller;
import com.ks.core.dto.OperateBase;
import com.ks.core.dto.SearchCriteriaBase;
import com.ks.core.base._ControllerBase;
import com.ks.core.dto.SearchCriteriaBase;
import com.ks.member.aop.Author;
import com.ks.member.controller.dto.MemberLevenRequest;
import com.ks.member.entity.MemberLevel;
import com.ks.member.service.IMemberLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ks.core.core.Result;

import java.util.Map;

/**
 * <p>
 * 会员-会员等级表 前端控制器
 * </p >
 *
 * @author kingdee123
 * @since 2020-12-17
 */
@RestController
@RequestMapping("/memberLevel")
@Api(value = "微会员等级管理模块", description = "微会员等级管理模块")
public class MemberLevelController extends _ControllerBase {

    @Autowired
    private IMemberLevelService iMemberLevelService;

    @PostMapping("/selectMemberLever")
    @ApiOperation(value = "会员等级查询", notes = "id,输入id查询")
    @Author
    public Object selectMemberLever(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = iMemberLevelService.selectMemberLever(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }

    @PostMapping("/selectAdminMemberLever")
    @ApiOperation(value = "系统会员等级查询", notes = "系统会员等级查询")
    public Object selectAdminMemberLever(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = iMemberLevelService.selectAdminMemberLever(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }

    @PostMapping("/addMemberLevel")
    @ApiOperation(value = "会员登记添加接口", notes = "会员登记添加接口")
    @Author
    public Object addMemberLevel(@RequestBody MemberLevel memberLevel) {
        int i = iMemberLevelService.addMemberLevel(getContext(), memberLevel);
        return Result.success(i);
    }

    @PostMapping("/deleteMembetLevel")
    @ApiOperation(value = "会员等级删除接口", notes = "会员等级删除接口")
    @Author
    public Object deleteMembetLevel(@RequestBody MemberLevenRequest request) {
        int i = iMemberLevelService.deleteMemberLevel(getContext(), request.getIds());
        return Result.success(i);
    }

    @PostMapping("/updateMemberLevel")
    @ApiOperation(value = "会员等级修改接口", notes = "会员等级修改接口")
    @Author
    public Object updateMemberLevel(@RequestBody MemberLevel memberLevel) {
        int i = iMemberLevelService.updateMemberLevel(getContext(), memberLevel);
        return Result.success(i);
    }
}